enum StorageType {
  Local,
  Secction
}

class FyStorage {
  Storage
  constructor(type: StorageType) {
    this.Storage = type === StorageType.Local ? localStorage : sessionStorage
  }
  get(key: string) {
    const store = this.Storage.getItem(key)
    if (store) {
      return JSON.parse(store)
    }
  }
  set(key: string, value: any) {
    this.Storage.setItem(key, JSON.stringify(value))
  }
  remove(key: string) {
    this.Storage.removeItem(key)
  }
  clear() {
    this.Storage.clear()
  }
}

const storage = new FyStorage(StorageType.Local)

export default storage